/* Start Header
*****************************************************************/
/*!
\file   NetWorkingTimer.h
\author <Liu Wei Long, weilong.liu, 250002510>
        <Liu Zhi Yang, zhiyang.liu, 300000111>
\par    <email: weilong.liu\@digipen.edu> 
        <email: zhiyang.liu\@digipen.edu> 
\date   <Apr 3, 2012>
\brief
Copyright (C) 2012 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the
prior written consent of DigiPen Institute of Technology is prohibited.
*/
/* End Header
*******************************************************************/
#ifndef _TIMER_H_
#define _TIMER_H_

#include <list>

class NetWorkingTimer
{

public:
	NetWorkingTimer() 
	{
		QueryPerformanceFrequency(&frequency);
		QueryPerformanceCounter(&currentTime);
		QueryPerformanceCounter(&previousTime);
	}
	~NetWorkingTimer() {}

	// Compute time difference
	bool			DiffTimeVal(LARGE_INTEGER start, LARGE_INTEGER end);
  float		  GetTimeDiff(LARGE_INTEGER start, LARGE_INTEGER end);
	// Get current time
	LARGE_INTEGER	GetTime( void );

	void			Update( void );
	unsigned int	CreateTimerEvent( float fTime, bool bRepeat = false, unsigned int unRepeatCount = -1 );
	bool			IsTimerEventComplete( unsigned int );
	bool			IsTimerEventValid( unsigned int );

private:
	// what the timer should contain
	struct TimerEvent
	{
		unsigned int unTimerID;
		unsigned int unCount;
		unsigned int unTotalCount;
		long double fTotal;
		float fCurr;
		bool bIsComplete;
		bool bIsRepeat;
	};

	LARGE_INTEGER	currentTime, 
					previousTime, 
					frequency;
	
	unsigned unIDCount;

	std::list<TimerEvent*>	teList;

};
#endif
